package net.chenlin.dp.modules.generator.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import net.chenlin.dp.common.entity.Page;
import net.chenlin.dp.common.entity.Query;
import net.chenlin.dp.common.entity.R;
import net.chenlin.dp.common.utils.CommonUtils;
import net.chenlin.dp.modules.generator.entity.SysTenantEntity;
import net.chenlin.dp.modules.generator.dao.SysTenantMapper;
import net.chenlin.dp.modules.generator.service.SysTenantService;

/**
 * 系统租户
 * @author zcl<yczclcn@163.com>
 */
@Service("sysTenantService")
public class SysTenantServiceImpl implements SysTenantService {

	@Autowired
	private SysTenantMapper sysTenantMapper;

    /**
     * 分页查询
     * @param params
     * @return
     */
	@Override
	public Page<SysTenantEntity> listSysTenant(Map<String, Object> params) {
		Query query = new Query(params);
		Page<SysTenantEntity> page = new Page<>(query);
		sysTenantMapper.listForPage(page, query);
		return page;
	}

    /**
     * 新增
     * @param sysTenant
     * @return
     */
	@Override
	public R saveSysTenant(SysTenantEntity sysTenant) {
		int count = sysTenantMapper.save(sysTenant);
		return CommonUtils.msg(count);
	}

    /**
     * 根据id查询
     * @param id
     * @return
     */
	@Override
	public R getSysTenantById(Long id) {
		SysTenantEntity sysTenant = sysTenantMapper.getObjectById(id);
		return CommonUtils.msg(sysTenant);
	}

    /**
     * 修改
     * @param sysTenant
     * @return
     */
	@Override
	public R updateSysTenant(SysTenantEntity sysTenant) {
		int count = sysTenantMapper.update(sysTenant);
		return CommonUtils.msg(count);
	}

    /**
     * 列表
     * @param id
     * @return
     */
	@Override
	public R batchRemove(Long[] id) {
		int count = sysTenantMapper.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

}
